<html>
<head><meta charset="utf-8"><title>Initial implementation of `if` and `match` in constants · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html">Initial implementation of `if` and `match` in constants</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="180990586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/180990586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#180990586">(Nov 18 2019 at 05:58)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/66507" target="_blank" title="https://github.com/rust-lang/rust/issues/66507">#66507</a> is now up with an initial implementation of RFC 2342 (allow <code>if</code> and <code>match</code> in constants <a href="https://github.com/rust-lang/rust/issues/49146" target="_blank" title="https://github.com/rust-lang/rust/issues/49146">#49146</a>). This is my first PR that adds a new feature to rust, so hopefully I didn't do anything too weird. Let me know if I missed anything obvious, or if you have ideas for tests (coverage is pretty sparse at the moment).</p>



<a name="180994655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/180994655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#180994655">(Nov 18 2019 at 07:58)</a>:</h4>
<p>Taking a look <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="180996836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/180996836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#180996836">(Nov 18 2019 at 08:45)</a>:</h4>
<p>omfgz <span aria-label="tears" class="emoji emoji-1f602" role="img" title="tears">:tears:</span> It's been three years (for me) and we are finally getting there</p>



<a name="181047869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181047869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181047869">(Nov 18 2019 at 19:31)</a>:</h4>
<p>I think we should try to come up with a comprehensive list of tests that we want. It's hard for me to keep track of ad-hoc suggestions in comments. If we weren't concerned about readability, we would want the cartesian product of every category below.</p>
<p>I personally feel comfortable not testing every const-context, but instead having just one test that does this (currently this is <code>control-flow/loop.rs</code>). Also I think we don't need to do both const/runtime asserts everywhere.</p>
<p>const contexts:<br>
- <code>const</code><br>
- <code>static</code> and <code>static mut</code><br>
- <code>const fn</code><br>
- <code>array initializer</code><br>
- <code>const generic param</code></p>
<p>branching constructs<br>
- <code>if</code><br>
- <code>if let</code><br>
- <code>match</code><br>
- <code>&amp;&amp;</code> and <code>||</code><br>
- single-arm <code>match</code></p>
<p>ways to check results<br>
- const <code>assert</code><br>
- runtime <code>assert</code></p>
<p>qualifs<br>
- <code>NeedsDrop</code><br>
- <code>HasMutInterior</code></p>



<a name="181097874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181097874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181097874">(Nov 19 2019 at 10:20)</a>:</h4>
<p>yea one const context totally suffices. Although I think we should just keep forbidding it in <code>static mut</code></p>



<a name="181097893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181097893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181097893">(Nov 19 2019 at 10:20)</a>:</h4>
<p>I don't want to think about the extra features available in <code>static mut</code> that may make this messy</p>



<a name="181098026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181098026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181098026">(Nov 19 2019 at 10:22)</a>:</h4>
<p>A few <code>const fn</code> tests would be good, too, because they are a bit different from constants due to having arguments</p>



<a name="181098199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181098199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181098199">(Nov 19 2019 at 10:24)</a>:</h4>
<p>if there's a few <code>if</code> tests, it seems sufficient to just keep <code>match</code> everywhere</p>



<a name="181098408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181098408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181098408">(Nov 19 2019 at 10:27)</a>:</h4>
<p><code>&amp;&amp;</code> and <code>||</code> are lowered in a way where I don't see how it would be beneficial to test them over just testing nested matches</p>



<a name="181098419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181098419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181098419">(Nov 19 2019 at 10:27)</a>:</h4>
<p>same with <code>if let</code></p>



<a name="181098480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181098480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181098480">(Nov 19 2019 at 10:28)</a>:</h4>
<p>so basically... test everything somewhere, but do the qualif and assert tests only with <code>match</code></p>



<a name="181106157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181106157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181106157">(Nov 19 2019 at 12:26)</a>:</h4>
<blockquote>
<p>yea one const context totally suffices.</p>
</blockquote>
<p>That depends entirely on how many differences there are between the contexts</p>



<a name="181106179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181106179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181106179">(Nov 19 2019 at 12:26)</a>:</h4>
<p>I think we can generally collapse "const, array init, enum discr" to just "const"</p>



<a name="181106202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181106202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181106202">(Nov 19 2019 at 12:27)</a>:</h4>
<p>but having some tests for all context would also be good</p>



<a name="181106269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181106269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181106269">(Nov 19 2019 at 12:28)</a>:</h4>
<blockquote>
<p>if there's a few if tests, it seems sufficient to just keep match everywhere</p>
</blockquote>
<p>This sort of assumes that the desugaring will always use <code>match</code>, but I don't think it will in the future</p>



<a name="181106300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181106300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181106300">(Nov 19 2019 at 12:28)</a>:</h4>
<p>To throw in more categories, we'll also need tests for <code>ref mut</code></p>



<a name="181106399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181106399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181106399">(Nov 19 2019 at 12:30)</a>:</h4>
<p>I think we should err on the side of high test coverage here as the analysis is complicated and the interactions are many</p>



<a name="181106428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181106428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181106428">(Nov 19 2019 at 12:30)</a>:</h4>
<p>(but we can also add tests over time...)</p>



<a name="181123910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181123910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181123910">(Nov 19 2019 at 15:47)</a>:</h4>
<blockquote>
<p>I don't want to think about the extra features available in <code>static mut</code> that may make this messy</p>
</blockquote>
<p>IMO it is more messy to special-case <code>static mut</code></p>



<a name="181142470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181142470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181142470">(Nov 19 2019 at 18:53)</a>:</h4>
<blockquote>
<blockquote>
<p>if there's a few if tests, it seems sufficient to just keep match everywhere</p>
</blockquote>
<p>This sort of assumes that the desugaring will always use <code>match</code>, but I don't think it will in the future</p>
</blockquote>
<p>The MIR-level checks that use dataflow analysis for <code>NeedsDrop</code> and <code>HasInteriorMut</code> won't really be affected by desugaring. It all ends up as a <code>SwitchInt</code> eventually. That's why I avoided replicating those tests across multiple high-level constructs.</p>



<a name="181142554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181142554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181142554">(Nov 19 2019 at 18:54)</a>:</h4>
<p>The HIR checks on the other hand should be tested across all high-level constructs.</p>



<a name="181142760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181142760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181142760">(Nov 19 2019 at 18:56)</a>:</h4>
<p>Which currently happens in <code>constrol-flow/loops.rs</code>, but I should replicate this test for <code>if</code>/<code>match</code> as well.</p>



<a name="181143749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181143749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181143749">(Nov 19 2019 at 19:06)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span>  <code>static mut</code> allows you to create <code>&amp;mut</code> slices, which is kind of scary, but <code>Deref</code> projections of them are forbidden, meaning you can't really mutate them.</p>



<a name="181155104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181155104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181155104">(Nov 19 2019 at 21:15)</a>:</h4>
<p>I think I lean towards allowing <code>if</code>/<code>match</code> in <code>static mut</code> for now, since it makes it easier for the community to try and break it. We should add this to <a href="https://github.com/rust-lang/rust/issues/49146" target="_blank" title="https://github.com/rust-lang/rust/issues/49146">#49146</a> as a question to resolve before stabilization though.</p>



<a name="181155163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181155163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dylan MacKenzie (ecstatic-morse) <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181155163">(Nov 19 2019 at 21:16)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I'd also like to write an inside rust blog post before this gets released on nightly explaining some of the weirdness around <code>Drop</code> types and interior mutability in consts.</p>



<a name="181198852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181198852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181198852">(Nov 20 2019 at 11:30)</a>:</h4>
<blockquote>
<p>The HIR checks on the other hand should be tested across all high-level constructs.</p>
</blockquote>
<p>right, but these don't need the combinatorial explosion for everything, just once per construct instead of once per test per construct per qualif bit</p>



<a name="181198883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181198883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181198883">(Nov 20 2019 at 11:31)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="124288">oli</span>  <code>static mut</code> allows you to create <code>&amp;mut</code> slices, which is kind of scary, but <code>Deref</code> projections of them are forbidden, meaning you can't really mutate them.</p>
</blockquote>
<p>well... that's something we'll want to allow at some point, so we'll have to keep it in mind</p>



<a name="181199136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181199136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181199136">(Nov 20 2019 at 11:36)</a>:</h4>
<p>We can certainly delay merging the PR until there's a blogpost explaining it</p>



<a name="181199790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181199790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181199790">(Nov 20 2019 at 11:49)</a>:</h4>
<p>side note when reading <a href="https://github.com/rust-lang/blog.rust-lang.org/pull/461/files" target="_blank" title="https://github.com/rust-lang/blog.rust-lang.org/pull/461/files">https://github.com/rust-lang/blog.rust-lang.org/pull/461/files</a> : while we should feature gate loops and conditions separately, we should probably stabilize together so we don't nudge ppl into writing loops via recursion</p>



<a name="181216278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181216278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181216278">(Nov 20 2019 at 15:17)</a>:</h4>
<p>agree wrt. stabilizing together; had the same thought</p>



<a name="181216341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181216341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181216341">(Nov 20 2019 at 15:17)</a>:</h4>
<p>I also think we should go nuts with using <code>rustc_const_unstable</code> everywhere as much as we can to test the implementation and see how far it takes us</p>



<a name="181216386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181216386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181216386">(Nov 20 2019 at 15:18)</a>:</h4>
<p>then we can FCP the actual stabilizations</p>



<a name="181216408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181216408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181216408">(Nov 20 2019 at 15:18)</a>:</h4>
<p>(well we need to stabilize the language features first)</p>



<a name="181216461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Initial%20implementation%20of%20%60if%60%20and%20%60match%60%20in%20constants/near/181216461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Initial.20implementation.20of.20.60if.60.20and.20.60match.60.20in.20constants.html#181216461">(Nov 20 2019 at 15:18)</a>:</h4>
<p>We'll also need to test stuff like <code>ref mut</code> btw</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>